# -*- coding: utf-8 -*-
import scrapy
from pyquery import PyQuery
from ..items import MobileNewsItem
from lxml import etree

class CnmoSpider(scrapy.Spider):
    name = 'cnmo'
    allowed_domains = ['cnmo.com']
    start_urls = ['http://www.cnmo.com/news/']

    def parse(self, response):
        s = etree.HTML(response.text)
        list = s.xpath('//div[@class="Newcon-list"]')
        for i in list:
            item = MobileNewsItem()
            item['title'] = i.xpath('./div[1]/a/text()')[0]
            item['url'] = i.xpath('./div[1]/a/@href')
            item['img_url'] = i.xpath('./div[2]/div[1]/a/img/@src')
            item['time'] = i.xpath('./div[1]/span/em[2]/text()')[0]
            item['source'] = '手机中国'
            item['author'] = ''
            yield item
